<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        function Person(name, age) {
            this.name = name;
            this.age = age;
        }


        Person.prototype.getName = function () {
            console.log(this.name);

        }

        var p = new Point("guanyu", 2);
        P.getName();     //这都是Es5的写法

        //ES6写法:
        class Point {
            constructor(name, age) {
                this.name=name;
                this.age= age;
            }


            getName() {
               console.log(this.name);
            }
        }

        var p=new Person();
        P.getName();





    </script>
</body>

</html>